import cv2
import numpy as np

img = cv2.imread('10.jpg')
h, w = img.shape[:2]

# 构造平移矩阵：向右平移50，向下平移30
M = np.float32([[1, 0, 500], [0, 1, 300]])
# 应用仿射变换，输出尺寸与原图一致
dst = cv2.warpAffine(img, M, (w, h))

cv2.imshow('Translate', dst)
cv2.waitKey(0)